package cn.jtcoding.springframework.aop.proxy;

import cn.jtcoding.springframework.aop.aspect.AspectInfo;
import lombok.extern.slf4j.Slf4j;

import java.lang.reflect.Proxy;
import java.util.List;

@Slf4j
public class JdkDynamicProxy extends AbstractDynamicProxy implements AopProxy {

    public JdkDynamicProxy(Object targetObj, List<AspectInfo> aspectInfoList) {
        super(targetObj, aspectInfoList);
    }

    @Override
    public Object getProxy() {
        return getProxy(targetObj.getClass().getClassLoader());
    }

    @Override
    public Object getProxy(ClassLoader classLoader) {
        return Proxy.newProxyInstance(classLoader, targetObj.getClass().getInterfaces(), this);
    }
}
